/*******************************************************************************
  ARTICLE	GAY, GOBBI, GONI (2025) "REVOLUTIONARY TRANSITIONS. INHERITANCE    
            CHANGE AND FERTILITY DECLINE" JOURNAL OF POLITICAL ECONOMY         
                                                                               
  AUTHORS	VICTOR GAY, PAULA GOBBI, MARC GONI                                 
  CONTACT	victor.gay@tse-fr.eu; paula.eugenia.gobbi@ulb.be; marc.goni@uib.no 
  VERSION	1.0 (MAY 2025)                                                     
  SOFTWARE	STATA SE 18                                                        
  LICENCE	MIT                                                                
--------------------------------------------------------------------------------

HENRY RESULTS APPENDIX DO FILE

This file produces the figures and tables in the Online Appendix using the Henry data.

Instructions: 
-------------
	gain access to Henry nominatif database and place enfants.sas7bdat and parents.sas7bdat in folder /1_raw_data/1_1_henri/ (see README for more details); 
	
	run 00_henry_data_prep.do once 
	
	open do-files from directory where they are placed; order matters; run whole code.
	
Contents: 
---------
	Program setup

	A. Supplementary tables
		Table A1: Summary statistics (women born in 1700–1803), Henry database.
		Table A3: Fertility control mechanisms, Henry database.
		Table A4: Inheritance reforms and child mortality, Henry database.
		Table A5: Inheritance reforms and childlessness across samples, Henry database.
		Table A7: Heterogeneous effects by categories of soil textures, Henry database.
		Table A8: Heterogeneous effects by soil conditions for small versus large farms, additional fertility outcomes, Henry database.
		Table A10: Relationship between inheritance reforms and distribution factors determining women's bargaining power in the household, Henry database.
	
	B. Supplementary figures
		Figure B5: Crude and net completed fertility for women born in 1650–1800, Henry database.
		Figure B6: Trends in completed fertility of mothers, Geni versus Henry.

	C. Implications for the Demographic Transition
		Figure C1: Overall implications of the inheritance reform for the demographic transition.
		Table C1: Fertility convergence after the inheritance reforms.

	D. Robustness of DD results, Henry database
		Table D1. Placebo test.
		Table D2: Alternative definitions of sample, exposure, and treatment group.
		Table D3: Effects of abolishing impartible inheritance.
		Table D4: Effects of including women in inheritances.
		Table D5: Robustness to migration and changes in mortality.
		Table D6: Adjusted fertility using the first-name repetition technique.
		Table D7: Robustness controlling for soil, climate, and terrain characteristics.
		Table D8: Robustness to excluding three outliers in Alps and Pyrenees with extreme ruggedness.
		Table D9: Alternative inference methods using the wild bootstrap procedure.
		Figure D1: Permutation tests.
		Figure D2. Sensitivity of main estimates to outliers
		Figure D3. Baseline vs. placebo exercises
		Figure D4. Alternative definitions of treatment.
		Figure D5: Conley adjusted standard errors with different distance cutoffs.

	H. Data appendix 
		Figure H1: Lent and advent marriages between 1700 and 1815.
		Figure H2: Balancedness on religiosity index.

Date last update: May 2025; Ran using STATA 18.5
*/
********************************************************************************

********************
* 0. PROGRAM SETUP *
********************

version 18
clear all
set more off

************************
* PACKAGE DEPENDENCIES *
************************

ssc install reghdfe, replace
ssc install ftools, replace
ssc install estout, replace
ssc install outreg2, replace
ssc install grc1leg2, replace
ssc install ritest, replace
ssc install coefplot, replace
ssc install acreg, replace
ssc install ranktest, replace
ssc install hdfe, replace

***************
* DIRECTORIES *
***************

global DAT 	= "../../3_outputs/3_1_datasets"
global APPTAB 	= "../../3_outputs/3_3_appendix/3_3_1_appendix_tables"
global APPFIG 	= "../../3_outputs/3_3_appendix/3_3_2_appendix_figures"
global TEMP = "../2_0_tempfiles"

timer on 1

********************************************************************************
*
* APPENDIX A. ADDITIONAL TABLES
*
********************************************************************************


* ==============================================================================
* Table A1: Summary statistics (women born in 1700–1803), Henry database.
* ------------------------------------------------------------------------------
use "$DAT/final-henry.dta", clear

* Main variables
* --------------
* Outcomes & treatment
label var nfert "Completed fertility (net)"
label var fert_gross "Completed fertility (gross)"
label var chdls "Childlessness"
label var mage "Age at marriage"
label var intmarg "Completed fertility of mothers (net)"
label var fbage "Age at first birth"
label var lbage "Age at last birth"
label var byear "Birth year"
label var AN_NA_MA "Birth year (husband)"
replace AN_NA_MA = . if AN_NA_MA==9999 | AN_NA_MA==0	// missing values as coded in Henry
label var affected "Inegalitarian inheritance before reform (treatment)"
gen affected0 = 1-affected
label var affected0 "Egalitarian inheritance before reform (control)"
label var partible "Partible inheritance before reform"
label var impart "Impartible inheritance before reform"
label var womexc "Women excluded in inheritance before reform"
label var wominc "Women included in inheritance before reform"
* Individual-level controls
label var SI_MA_FE "Literacy"
label var SI_MA_MA "Literacy (husband)"
label var TYP_FICH "Accuracy of Henry's entry"
gen wmotheralive = (SU_ME_FE==1)
label var wmotheralive "Survival of wife's mother"
gen hmotheralive = (SU_ME_MA==1)
label var hmotheralive "Survival of husband's mother"
gen wfatheralive = (SU_PE_FE==1)
label var wfatheralive "Survival of wife's father"		    		
gen hfatheralive = (SU_PE_MA==1)
label var hfatheralive "Survival of husband's father"
gen agediff = AN_NA_FE - AN_NA_MA if (AN_NA_MA!=0 & AN_NA_MA!=9999 & AN_NA_FE!=0 & AN_NA_FE!=9999)
label var agediff "Age difference (husband-wife)"
* Municipality-level controls
label var logpwheat "Wheat price (log)"
label var vidxcivil "Religiosity index"
label var dist_eveche "Distance to religious centre (Eveche)"
label var dist_bailliage "Distance to legal centre (Bailliage capital)"
label var dist_subdeleg "Distance to territorial admin centre (subdelegation)"
label var dist_recette "Distance to tax centre (Recette)"
label var dist_socpol "Distance to political society"
label var dist_rebellion_state_1779_1789 "Distance to rebellion in 1779-89"
* sample
* -----------------
keep if byear>=1700 // born after 1700
xi: reghdfe nfert T01xaffected, absorb(byear) cluster(villagenum)
keep if e(sample)==1 // regression sample
* table
* -----
eststo sumbase: estpost summ nfert intmarg chdls fert_gross mage ///
	fbage lbage byear AN_NA_MA partible impart womexc wominc affected affected0 ///
	wmotheralive hmotheralive wfatheralive hfatheralive SI_MA_FE SI_MA_MA TYP_FICH agediff ///
	logpwheat vidxcivil dist_eveche dist_bailliage dist_subdeleg dist_socpol dist_recette  dist_rebellion_state_1779_1789 dist_cassini dist_post
estadd local obs = `e(N)'
esttab sumbase using "$APPTAB/tableA1.tex", ///
	cells("mean(fmt(2)) sd(fmt(2)) count(fmt(0))") label noobs replace
* -----
* sample average before the reform in treated areas (for the introduction)
sum nfert if byear<1754 & wominc==0 & impart==1
* ==============================================================================


* ==============================================================================
* Table A2: Accuracy of Henry forms.
* Not produced with STATA
* ------------------------------------------------------------------------------


* ==============================================================================
* Table A3: Fertility control mechanisms, Henry database.
* ------------------------------------------------------------------------------
use "$DAT/final-henry.dta", clear

* Sample: 
keep if byear>=1700 	// born after 1700
qui xi: reghdfe nfert T01xaffected, absorb(byear) cluster(villagenum)
keep if e(sample)==1	// regression sample

* Regressions
global flextrends prewheat ldensity_1793 vidxcivil ldist_eveche ldist_socpol ldist_rebellion_state_1779_1789 ldist_bailliage ldist_subdeleg ldist_recette ldist_cassini ldist_post
local re = "replace"
foreach y in mage fsbage TFB rspan binterval{
global depvar `y'
reghdfe $depvar c.T##i.affected i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableA3.tex", ///
	keep(1.affected#c.T) nocons ///
	title("Fertility-control mechanims") ctitle("`x'") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long `re'
local re = ""
}
* ==============================================================================


* ==============================================================================
* Table A4: Inheritance reforms and child mortality, Henry database.
* ------------------------------------------------------------------------------
use "$DAT/final-henry.dta", clear

* Sample (parents)
keep if byear>=1700 	// born after 1700
qui xi: reghdfe nfert T01xaffected, absorb(byear) cluster(villagenum)
keep if e(sample)==1	// regression sample

* Child mortality indicator
preserve 
import sas using "../../1_raw_data/1_1_henri/enfants.sas7bdat", clear
gen chdage = AN_DE_EN-AN_NA_EN		// Children's age at death
replace chdage=. if AN_DE_EN==0 | AN_NA_EN==9999 
replace chdage=. if AN_DE_EN<AN_NA_EN 
gen infmort = 0
replace infmort = 1 if chdage<6
label var infmort "=1 if died before age 6"

* Cummins (2020) adjustment to child mortality
gen missdeath = (AN_DE_EN==9999 | AN_DE_EN==0 | AN_DE_EN==.)	// missing death record 
bys N0_FICH NENF PR_ENF: gen rep_pre = (_N>1)					// repeated 3 letters of first forename
gen rep_pre_mis = (rep_pre==1 & missdeath==1)					// repeated 3 letters + missing death record
gen infmortadj = 0
replace infmortadj = 1 if chdage<6
replace infmortadj = 1 if rep_pre_mis==1
label var infmortadj "=1 if died before age 6 (adjusted)"

* Children as unit of observation
gen chbyear = AN_NA_EN
label var chbyear "child birth year"
keep N0_FICH NENF infmort infmortadj chbyear SEX_ENF
tempfile enfants1
save `enfants1', replace
restore
merge 1:m N0_FICH NENF using `enfants1', keep(mas mat)

* Treatment variables (children as unit of observation)
gen chT = (chbyear>1793)
replace chT = . if chbyear==.
gen chTxaffected = chT*affected
label var chTxaffected "Impartible x Child born post-reform"

* Sample (children)
drop if chbyear==. 
keep if chbyear>1700 & chbyear<1800

* Regressions
egen parentFE = group(N0_FICH NENF)
local re replace
local l1 = "boys"
local l2 = "girls"
local i=1
local panels="A B C"
foreach y in infmort infmortadj{
local pan `: word `i' of `panels''
xi: reghdfe `y' chTxaffected, absorb(chbyear parentFE) cluster(villagenum)
summ `y' if e(sample)==1
local mdv = `r(mean)'
outreg2 using "$APPTAB/tableA4-panel`pan'.tex", ///
	keep(impart chTxaffected) nocons ///
	title("Child mortality") ctitle("all") ///
	addtext(Cohort FE of child, Y, Parents FE, Y) ///
	addstat(N clusters, `e(N_clust)', Mean dep var, `mdv') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) tex(fragment) long replace
local re = ""
foreach g in 2 1{
xi: reghdfe `y' chTxaffected if SEX_ENF==`g', absorb(chbyear parentFE) cluster(villagenum)
summ `y' if e(sample)==1
local mdv = `r(mean)'
outreg2 using "$APPTAB/tableA4-panel`pan'.tex", ///
	keep(impart chTxaffected) nocons ///
	title("Child mortality") ctitle("`l`g''") ///
	addtext(Cohort FE of child, Y, Parents FE, Y) ///
	addstat(N clusters, `e(N_clust)', Mean dep var, `mdv') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) tex(fragment) long
}
local i = `i'+1
}
* ==============================================================================


* ==============================================================================
* Table A5: Inheritance reforms and childlessness across samples, Henry database.
* ------------------------------------------------------------------------------
use "$DAT/final-henry.dta", clear

* Sample: 
keep if byear>=1700 	// born after 1700
qui xi: reghdfe nfert T01xaffected, absorb(byear) cluster(villagenum)
keep if e(sample)==1	// regression sample
global sample1 = "fert_gross>0 & fert_gross!=. & dage>=40 & sdage>=40 & dage!=."

* Regressions:
global flextrends vidxcivil ldist_eveche ldist_socpol ldist_rebellion_state_1779_1789 ldist_bailliage ldist_subdeleg ldist_recette ldist_cassini ldist_post ldensity_1793 prewheat
label var T01xaffected "Reform x Fertile"
* col (1)
reghdfe chdls T01xaffected, absorb(byear villagenum) cluster(villagenum) nofoot
qui summ chdls if e(sample)==1, d
local mdv = `r(mean)'
local std = `r(sd)'
local effsiz = _b[T01xaffected]/`mdv'
outreg2 using "$APPTAB/tableA5.tex", ///
	keep(T01xaffected) nocons ///
	ctitle("chdls | base") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, ., Flexible trends, ., N clusters, `e(N_clust)') ///
	addstat(Mean dep var, `mdv', Effect size b/mean, `effsiz') nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(3) tex(fragment) long replace
* col (2)
reghdfe chdls T01xaffected i.SI_MA_FE , absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE ) cluster(villagenum) nofoot
qui summ chdls if e(sample)==1, d
local mdv = `r(mean)'
local std = `r(sd)'
local effsiz = _b[T01xaffected]/`mdv'
outreg2 using "$APPTAB/tableA5.tex", ///
	keep(T01xaffected) nocons ///
	ctitle("chdls | base") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, ., N clusters, `e(N_clust)') ///
	addstat(Mean dep var, `mdv', Effect size b/mean, `effsiz') nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(3) tex(fragment) long
* col (3)
reghdfe chdls T01xaffected i.SI_MA_FE logpwheat , absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum) nofoot
qui summ chdls if e(sample)==1, d
local mdv = `r(mean)'
local std = `r(sd)'
local effsiz = _b[T01xaffected]/`mdv'
outreg2 using "$APPTAB/tableA5.tex", ///
	keep(T01xaffected) nocons ///
	ctitle("chdls | base") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, N clusters, `e(N_clust)') ///
	addstat(Mean dep var, `mdv', Effect size b/mean, `effsiz') nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(3) tex(fragment) long
* col (4)
reghdfe chdls T01xaffected if $sample1 , absorb(byear villagenum) cluster(villagenum) nofoot
qui summ chdls if e(sample)==1, d
local mdv = `r(mean)'
local std = `r(sd)'
local effsiz = _b[T01xaffected]/`mdv'
outreg2 using "$APPTAB/tableA5.tex", ///
	keep(T01xaffected) nocons ///
	ctitle("chdls | willing") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, ., Flexible trends, ., N clusters, `e(N_clust)') ///
	addstat(Mean dep var, `mdv', Effect size b/mean, `effsiz') nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(3) tex(fragment) long
* col (5)
reghdfe chdls T01xaffected i.SI_MA_FE if $sample1 , absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE ) cluster(villagenum) nofoot
qui summ chdls if e(sample)==1, d
local mdv = `r(mean)'
local std = `r(sd)'
local effsiz = _b[T01xaffected]/`mdv'
outreg2 using "$APPTAB/tableA5.tex", ///
	keep(T01xaffected) nocons ///
	ctitle("chdls | willing") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, ., N clusters, `e(N_clust)') ///
	addstat(Mean dep var, `mdv', Effect size b/mean, `effsiz') nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(3) tex(fragment) long
* col (6)
reghdfe chdls T01xaffected i.SI_MA_FE logpwheat if $sample1 , absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum) nofoot
qui summ chdls if e(sample)==1, d
local mdv = `r(mean)'
local std = `r(sd)'
local effsiz = _b[T01xaffected]/`mdv'
outreg2 using "$APPTAB/tableA5.tex", ///
	keep(T01xaffected) nocons ///
	ctitle("chdls | willing") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, N clusters, `e(N_clust)') ///
	addstat(Mean dep var, `mdv', Effect size b/mean, `effsiz') nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(3) tex(fragment) long
* ==============================================================================


* ==============================================================================
* Table A6: List of sources describing local effects of the inheritance reforms for land fragmentation.
// NOT PRODUCED WITH STATA
* ==============================================================================


* ==============================================================================
* Table A7: Heterogeneous effects by categories of soil textures, Henry database.
* ------------------------------------------------------------------------------
use "$DAT/final-henry.dta", clear

set seed 03122024

global flextrends prewheat ldensity_1793 vidxcivil ldist_eveche ldist_socpol ldist_rebellion_state_1779_1789 ldist_bailliage ldist_subdeleg ldist_recette ldist_cassini ldist_post

* sample
keep if byear>=1700 // born after 1700
qui reghdfe nfert T01xaffected i.SI_MA_FE logpwheat, nocons absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
keep if e(sample)==1 // regression sample

* Heterogeneous effects DD regressions (4 categories)
gen TxFxcoarse = T01xaffected*(text1_cat==1)
gen TxFxmedium = T01xaffected*(text1_cat==2)
gen TxFxmediumfine = T01xaffected*(text1_cat==3)
gen TxFxfine = T01xaffected*(text1_cat==4)
label var TxFxcoarse "T x F x Coarse (sandy)"
label var TxFxmedium "T x F x Medium" 
label var TxFxmediumfine "T x F x Medium fine"
label var TxFxfine "T x F x Fine"

* Regressions
global treatvars TxFxcoarse TxFxmedium TxFxmediumfine TxFxfine
qui reghdfe nfert $treatvars i.SI_MA_FE logpwheat, nocons absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
local nobs = `e(N)'
outreg2 using "$APPTAB/tableA7.tex", ///
	keep($treatvars ) nocons noobs nor2 ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Soil texture X cohort FE, N, Ruggedness X cohort FE, N, Soil conditions based on, Soil texture, N, `nobs') ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long replace
qui reghdfe nfert $treatvars i.SI_MA_FE logpwheat, nocons absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends text1 ruggedness)#byear) cluster(villagenum)
local nobs = `e(N)'
outreg2 using "$APPTAB/tableA7.tex", ///
	keep($treatvars ) nocons noobs nor2 ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Soil texture X cohort FE, Y, Ruggedness X cohort FE, Y, Soil conditions based on, Soil texture, N, `nobs') ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
qui reghdfe intmarg $treatvars i.SI_MA_FE logpwheat, nocons absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
local nobs = `e(N)'
outreg2 using "$APPTAB/tableA7.tex", ///
	keep($treatvars ) nocons noobs nor2 ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Soil texture X cohort FE, N, Ruggedness X cohort FE, N, Soil conditions based on, Soil texture, N, `nobs') ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
qui reghdfe intmarg $treatvars i.SI_MA_FE logpwheat, nocons absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends text1 ruggedness)#byear) cluster(villagenum)
local nobs = `e(N)'
outreg2 using "$APPTAB/tableA7.tex", ///
	keep($treatvars ) nocons noobs nor2 ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Soil texture X cohort FE, Y, Ruggedness X cohort FE, Y, Soil conditions based on, Soil texture, N, `nobs') ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
* ==============================================================================


* ==============================================================================
* Table A8: Heterogeneous effects by soil conditions for small versus large farms, additional fertility outcomes, Henry database.
* ------------------------------------------------------------------------------
use "$DAT/final-henry.dta", clear

set seed 03122024

global flextrends prewheat ldensity_1793 vidxcivil ldist_eveche ldist_socpol ldist_rebellion_state_1779_1789 ldist_bailliage ldist_subdeleg ldist_recette ldist_cassini ldist_post

* sample
keep if byear>=1700 // born after 1700
qui reghdfe nfert T01xaffected i.SI_MA_FE logpwheat, nocons absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
keep if e(sample)==1 // regression sample

* Heterogeneous effects DD regressions
gen T01xaffectedXsclc1 = .
gen T01xaffectedXsclc0 = .
label var T01xaffectedXsclc1 "Reform X Fertile (soil conditions for large farms)"
label var T01xaffectedXsclc0 "Reform X Fertile (soil conditions for small farms)"
global treatvars T01xaffectedXsclc1 T01xaffectedXsclc0

// Based on soil texture
replace T01xaffectedXsclc1 = T01xaffected*(text1_cat==1)
replace T01xaffectedXsclc0 = T01xaffected*(text1_cat!=1)
* col (1)
qui reghdfe intmarg $treatvars i.SI_MA_FE logpwheat, nocons absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends text1 ruggedness)#byear ) cluster(villagenum)
local nobs = `e(N)'
test _b[T01xaffectedXsclc1] - _b[T01xaffectedXsclc0] = 0
local pval = round(`r(p)',0.001)
outreg2 using "$APPTAB/tableA8.tex", ///
	keep($treatvars ) nocons noobs nor2 ///
	addtext(p value difference, `pval', Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Soil conditions based on, Soil texture, N, `nobs') ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long replace
* col (2)
qui reghdfe chdls $treatvars i.SI_MA_FE logpwheat, nocons absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends text1 ruggedness)#byear ) cluster(villagenum)
local nobs = `e(N)'
test _b[T01xaffectedXsclc1] - _b[T01xaffectedXsclc0] = 0
local pval = round(`r(p)',0.001)
outreg2 using "$APPTAB/tableA8.tex", ///
	keep($treatvars ) nocons noobs nor2 ///
	addtext(p value difference, `pval', Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Soil conditions based on, Soil texture, N, `nobs') ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long

// Based on terrain ruggedness
qui bys insee_com: gen ruggedness_munlevel = ruggedness if _n==1
qui summ ruggedness_munlevel, d
qui gen iruggedness = (ruggedness<=`r(p50)')
replace T01xaffectedXsclc1 = T01xaffected*(iruggedness)
replace T01xaffectedXsclc0 = T01xaffected*(1-iruggedness)
* col (3)
qui reghdfe intmarg $treatvars i.SI_MA_FE logpwheat, nocons absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends text1 ruggedness)#byear ) cluster(villagenum)
local nobs = `e(N)'
test _b[T01xaffectedXsclc1] - _b[T01xaffectedXsclc0] = 0
local pval = round(`r(p)',0.001)
outreg2 using "$APPTAB/tableA8.tex", ///
	keep($treatvars ) nocons noobs nor2 ///
	addtext(p value difference, `pval', Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Soil conditions based on, Terrain ruggedness, N, `nobs') ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
* col (4)
qui reghdfe chdls $treatvars i.SI_MA_FE logpwheat, nocons absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends text1 ruggedness)#byear) cluster(villagenum)
local nobs = `e(N)'
test _b[T01xaffectedXsclc1] - _b[T01xaffectedXsclc0] = 0
local pval = round(`r(p)',0.001)
outreg2 using "$APPTAB/tableA8.tex", ///
	keep($treatvars ) nocons noobs nor2 ///
	addtext(p value difference, `pval', Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Soil conditions based on, Terrain ruggedness, N, `nobs') ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
* ==============================================================================


* ==============================================================================
* Table A10: Relationship between inheritance reforms and distribution factors
* determining women's bargaining power in the household, Henry database.
* ------------------------------------------------------------------------------
use "$DAT/final-henry.dta", clear

* Sample: 
keep if byear>=1700 // born after 1700
qui reghdfe nfert T01xaffected, absorb(byear villagenum) cluster(villagenum)
keep if e(sample)==1 // regression sample

* Regressions
label var SI_MA_MA "Husband literate (0/1)"
label var T01xaffected "Reform x Fertile"
global flextrends prewheat ldensity_1793 vidxcivil ldist_eveche ldist_socpol ldist_rebellion_state_1779_1789 ldist_bailliage ldist_subdeleg ldist_recette ldist_cassini ldist_post

local re = "replace"
foreach y in nfert relage reledu SI_MA_MA{
global depvar `y'
// Panel A
qui reghdfe $depvar T01xaffected i.SI_MA_FE i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
qui summ $depvar if e(sample)==1, d
local mdv = `r(mean)'
local std = `r(sd)'
local effsiz = abs(_b[T01xaffected]/`mdv')
outreg2 using "$APPTAB/tableA10.tex", ///
	keep(T01xaffected) nocons ///
	ctitle("`y'") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, N clusters, `e(N_clust)') ///
	addstat(Mean dep var, `mdv', Effect size b/mean, `effsiz') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(3) tex(fragment) long `re'

local re = " "
}
* ==============================================================================


********************************************************************************
*
* APPENDIX B. ADDITIONAL FIGURES
*
********************************************************************************


* ==============================================================================
* Figure B5: Crude and net completed fertility for women born in 1650–1800, Henry database.
* ------------------------------------------------------------------------------
use "$DAT/final-henry.dta", clear
keep if byear!=.		// sample
keep if fert_gross!=0	// sample 2: intensive margin (gross)
count if byear>1650
collapse fert_gross nfert, by(byear)
tsset byear
label var byear "Woman's birth year"
tssmooth ma mafert = fert_gross, window(2 1 2)
tssmooth ma mafertnet = nfert, window(2 1 2)
twoway (scatter fert_gross byear if byear>1650, m(d)  mcolor(black) mlcolor(black) mlw(thin) msize(small)) ///
	   (tsline mafert if byear>1650, lcolor(black) lwidth(medthick)) ///
	   (scatter nfert   byear if byear>1650, m(dh) mcolor(gray)  mlcolor(gray)  mlw(thin) msize(small)) ///
	   (tsline mafertnet if byear>1650, lcolor(gray) lwidth(medthin)) ///
	   (pcarrowi 5.35 1754 5.35 1800 (1) " Fertile after reform", lcolor(red) mc(red) mlabcolor(red)), ///
	   ylabel(2(0.5)5.5) ytitle("Completed fertility of mothers") 	 ///
	   xlabel(1650(25)1800) xtitle("Mother's birth cohort") ///
	   xline(1754, lcolor(red) lpattern(dash)) ///
	   legend(on order(1 "crude" 3 "net" 2 "5-year moving average") pos(7) ring(0) region(lc(black)) rows(1)) ///
	   graphregion(fcolor(white))
graph export "$APPFIG/figureB5.pdf", as(pdf) name("Graph") replace	  
* ==============================================================================


* ==============================================================================
* Figure B6: Trends in completed fertility of mothers, Geni versus Henry.
* ------------------------------------------------------------------------------

* HENRY
use "$DAT/final-henry.dta", clear
keep if byear!=.		// sample
count if byear>1650
replace fert_gross = . if fert_gross==0
replace nfert = . if nfert==0
collapse fert_gross nfert, by(byear)
rename fert_gross fhenry_crude
rename nfert fhenry_net
tempfile henryfamilinx
save `henryfamilinx', replace

* FAMILINX
/*
Note: First requires runing 04_familinx-data-prep.do in folder /2_scripts/2_1_data.
*/
import delimited "../../3_outputs/3_1_datasets/familinx-year-series.csv", clear 
merge 1:1 byear using `henryfamilinx', nogen
tempfile henryfamilinx
save `henryfamilinx', replace

* GENI
* Same Data used for the RDD 
import delimited "../../3_outputs/3_1_datasets/fr-clean.csv", encoding(UTF-8) delimiter(comma) bindquote(strict) stringcols(1 3 5 6 7) clear
keep if birth_start_year<1851
keep if gender=="f"
keep if born_france==1
keep if twoplus_flag==1

* 20km away from Heny
merge 1:1 profile_id using "../../1_raw_data/1_18_fertility_trends/20km-from-henry.dta"
rename net geni_net20
replace geni_net20 = . if geni_net20==0
gen geni_net = nkids-d5  
replace geni_net = . if geni_net==0 
collapse geni_net geni_net20, by(birth_start_year)
rename birth_start_year byear
merge 1:1 byear using `henryfamilinx', nogen

* FIGURE
rename byear year
label var year "Mother's birth year"
tsset year
tssmooth ma mageni_net = geni_net, window(5 1 5)
tssmooth ma mageni_net20 = geni_net20, window(5 1 5)
tssmooth ma mafert_net = fert_net, window(5 1 5)
tssmooth ma mahenry_net = fhenry_net, window(5 1 5)
* figure
twoway (tsline mageni_net if year>1700 & year<1810,  lc(gray)  lw(medthick)) ///
	   (tsline mafert_net if year>1700 & year<1810,  lc(gray)  lw(medthick) lp(shortdash)) ///
	   (tsline mahenry_net if year>1700 & year<1810, lc(black) lw(medthick)), ///
	   ylabel(1(0.5)5) title("Panel A: all", color(black)) xtitle("Mother's birth cohort") ytitle("Births") ///
	   legend(on order(1 "Geni" 2 "Familinx" 3 "Henry") rows(1) pos(7) ring(0) region(lc(black))) ///
	   name(pA, replace) graphregion(fc(white) lc(white))
twoway (tsline mageni_net20 if year>1700 & year<1810, lc(gray) lw(medthick)) ///
	   (tsline mafert_net if year>1700 & year<1810,  lc(gray)  lw(medthick) lp(shortdash)) ///
	   (tsline mahenry_net if year>1700 & year<1810, lc(black) lw(medthick)), ///
	   ylabel(1(0.5)5) title("Panel B: within 20km from Henry", color(black)) xtitle("Mother's birth cohort") ytitle("Births") ///
	   legend(on order(1 "Geni" 2 "Familinx" 3 "Henry") rows(1) pos(7) ring(0) region(lc(black))) ///
	   name(pB, replace) graphregion(fc(white) lc(white))
grc1leg2 pA pB, legendfrom(pA) graphregion(fc(white) lc(white))
graph export "$APPFIG/figureB6.pdf", as(pdf) name("Graph") replace
* ==============================================================================


********************************************************************************
*
* APPENDIX C. IMPLICATIONS
*
********************************************************************************

* ==============================================================================
* Figure C1: Overall implications of the inheritance reform for the demographic transition.
* ------------------------------------------------------------------------------
use "$DAT/final-henry.dta", clear

* counterfactual values
qui reg nfert i.SI_MA_FE logpwheat i.byear i.villagenum i.TYP_FICH i.SU_PE_FE i.SU_ME_FE c.prewheat##i.byear c.ldensity_1793##i.byear c.vidxcivil##i.byear c.ldist_eveche##i.byear c.ldist_socpol##i.byear c.ldist_rebellion_all_1779_1789##i.byear c.ldist_bailliage##i.byear c.ldist_subdeleg##i.byear c.ldist_recette##i.byear c.ldist_cassini##i.byear c.ldist_post##i.byear affected T01xaffected if byear>=1700, vce(cluster villagenum)
replace T01xaffected=0 if byear>=1700
predict fert_coun if byear>=1700
replace fert_coun = nfert if T==0

* figure
gen year1 = byear+40
gen year2 = year1
replace year1 = 1940 if year1==1644
replace year1 = 1855 if year1==1652
gen fobs = . 
gen fcou = . 

summ nfert if year1>=1700 & year1<1725
local p1 = round(`r(mean)',0.01)
replace fobs = `p1' if year1==1725

summ nfert if year1>=1768 & year1<=1793
local p2 = round(`r(mean)',0.01)
replace fobs = `p2' if year1==1793

summ nfert if year1>=1793 & year1<=1818
local p3 = round(`r(mean)',0.01)
replace fobs = `p3' if year1==1818
summ fert_coun if year1>=1793 & year1<=1818
local c3 = round(`r(mean)',0.01)
replace fcou = `c3' if year1==1818

* Enquete famille (see paper for more details on sources)
replace fobs = 2.01 if year1==1940
local p4 = 2.01

* Blanc Wacziarg (see paper for more details on sources)
gen fobs2 = .
replace fobs2 = 2.43 if year1==1770

* Mouvement de la population (see paper for more details on sources)
gen fobs3 = .
replace fobs3 = 2.13 if year1==1855
replace fobs = 2.13 if year1==1855

label var year2 "Birth cohorts"
label var year1 "Years reproductive span ends"
keep if fobs!=. | fobs2!=. | fobs3!=.
replace year2 = year1
collapse fobs fcou fobs2 fobs3, by(year1 year2)
twoway 	(line fobs year1 if year1<1849, lc(stc1) lwidth(vthin)) ///
		(scatter fobs year1 if year1>=1849, mlab(fobs) mlabp(1) mlabc(stc1) mc(stc1) msy(Sh) msiz(medium)) ///
		(scatter fobs year2 if year1< 1849, mlab(fobs) mlabp(1) mlabc(stc1) mc(stc1) msy(triangle) msiz(medium) xaxis(2)) ///
		(scatter fobs year1 if year1< 1849, mc(stc1) msy(triangle) msiz(medium)) ///
		(scatter fcou year1, mlab(fcou) mlabp(1) mlabc(gray) msiz(medium) mc(gray)) ///
		(scatter fobs2 year1, mlab(fobs2) mlabp(12) mc(stc3) mlabc(stc3) msy(Sh) msiz(medium)) ///
		(scatter fobs3 year1, mlab(fobs3) mlabp(1) mc(black) mlabc(black) msy(Sh) msiz(medium)) ///
		(line fobs year1 if year1>1800, lc(stc1) lpattern(vshortdash)) ///
		, ylabel(1.9(0.1)2.7) xline(1850 1936) xline(1793, lc(stc2)) ytitle(Completed fertility) ///
		xlabel(1725 "1700-25" 1793 "1768-93" 1818 "1793-1818" 1855 "1855" 1940 "1939-44", axis(1) labsize(small) angle(45)) ///
		xlabel(1725 "1660-85" 1793 "1728-53" 1818 "1753-1778" 1940 "1899-1904", axis(2) labsize(small) angle(45)) ///
		xmlabel(1740 " " 1950 " ", notick axis(1)) xmlabel(1740 " "1950 " ", notick axis(2)) ///
		text(1.95 1793 " Reform", place(e) size(small) color(stc2)) ///
		text(1.92 1793 " (1793)", place(e) size(small) color(stc2)) ///
		text(1.95 1850 " End first phase", place(e) size(small)) ///
		text(1.92 1850 " (1850)", place(e) size(small)) ///
		text(1.95 1936 " End DT", place(e) size(small)) ///
		text(1.92 1936 " (1936)", place(e) size(small)) ///
		legend(on order(3 "Henry dataset" 2 "Enquête Famille" 5 "Blanc & Wacziarg" 6 "Mouvement Population" 4 "No reform""counterfactual"))
graph export "$APPFIG/figureC1.pdf", as(pdf) name("Graph") replace
* ==============================================================================


* ==============================================================================
* Table C1: Fertility convergence after the inheritance reforms.
* ------------------------------------------------------------------------------

* End of the first phase of the DT 
* --------------------------------
* Source: SGF (1861)'s vital statistics data

* Mean France
use "../../1_raw_data/1_18_fertility_trends/mouvement_population.dta", clear
drop if dep =="CORSE"
sum fertility
local f11 = `r(mean)'

* Egalitarian vs Inegalitarian areas
keep dep fertility
expand 2, generate(imp_exc)
merge m:1 dep imp_exc using "../../1_raw_data/1_18_fertility_trends/dep_treat_weight_1851.dta", assert(1 3) keep(3) nogenerate 
gen egalitarian = 0
replace egalitarian = 1 if imp_exc == 1
drop imp_exc
egen mean_ceb_net = mean(fertility), by(dep egalitarian)

by egalitarian, sort: summarize fertility [aw=dep_treat_weight]


summarize fertility [aw=dep_treat_weight] if egalitarian==1
local f12 = `r(mean)'
local f13 = `r(sd)'
summarize fertility [aw=dep_treat_weight] if egalitarian==0
local f14 = `r(mean)'
local f15 = `r(sd)'
reg mean_ceb_net egalitarian [aw=dep_treat_weight]
local f16 = r(table)[4,1]

* End of the DT 
* -------------
* Source: Enquêtes Famille 1954 data

use "../../1_raw_data/1_18_fertility_trends/fam1954.dta", clear
destring anf, generate(birthy)
drop if birthy>8 & birthy<99
replace birthy=1899 if birthy==99
replace birthy=birthy+1900 if birthy!=1899

* keep ever married only
drop if m=="0" | m=="1"

* children ever born
drop if nte=="" | nte=="--" | nte=="-0"
destring nte, generate(ceb)
tab ceb

* children birth dates
replace ane03="" if ane03=="7-" | ane03=="4-" | ane03=="96"
// Loop through variables ane01 to ane20
forvalues i = 1/9 {
// Convert string variable to numeric
replace ane0`i' = "" if ane0`i'=="--"
destring ane0`i', replace
// Add 1900 to non-missing values
replace ane0`i' = ane0`i' + 1900 if !missing(ane0`i')
}
forvalues i = 10/20 {
// Convert string variable to numeric
replace ane`i' = "" if ane`i'=="--"
destring ane`i', replace
// Add 1900 to non-missing values
replace ane`i' = ane`i' + 1900 if !missing(ane`i')
}

* children death dates 
// Loop through variables ade01 to ade20
forvalues i = 1/9 {
// Convert string variable to numeric
replace ade0`i' = "" if ade0`i'=="--"
destring ade0`i', replace
// Add 1900 to non-missing values
replace ade0`i' = ade0`i' + 1900 if !missing(ade0`i')
}
forvalues i = 10/20 {
// Convert string variable to numeric
replace ade`i' = "" if ade`i'=="--"
destring ade`i', replace
// Add 1900 to non-missing values
replace ade`i' = ade`i' + 1900 if !missing(ade`i')
}

* children who survived to age 6
forvalues i = 1/9 {
// Convert string variable to numeric
gen surv`i' = 0 if ade0`i'- ane0`i'<6
replace surv`i' = 1 if !missing(ane0`i') & surv`i' != 0
}
forvalues i = 10/20 {
// Convert string variable to numeric
gen surv`i' = 0 if ade`i'- ane`i'<6
replace surv`i' = 1 if !missing(ane`i') & surv`i' != 0
}
egen ceb_net = rowtotal(surv1-surv20)

* Mean France
summ ceb_net if birth<1905
local f21 = `r(mean)'

* Egalitarian vs Inegalitarian areas
keep ceb_net birth ceb reg
expand 2, generate(imp_exc)
merge m:1 reg imp_exc using "../../1_raw_data/1_18_fertility_trends/reg_treat_weight_1954.dta", assert(1 3) keep(3) nogenerate 
generate egalitarian = 0
replace egalitarian = 1 if imp_exc == 1
drop imp_exc
order reg reg_name egalitarian reg_treat_weight, first
sort reg egalitarian birthy
keep if birth<1905
drop birth ceb
egen mean_ceb_net = mean(ceb_net), by(reg reg_name egalitarian)
drop ceb_net
duplicates drop
summarize mean_ceb_net [aw=reg_treat_weight] if egalitarian==1
local f22 = `r(mean)'
local f23 = `r(sd)'
summarize mean_ceb_net [aw=reg_treat_weight] if egalitarian==0
local f24 = `r(mean)'
local f25 = `r(sd)'
reg mean_ceb_net egalitarian [aw=reg_treat_weight]
local f26 = r(table)[4,1]

* table
matrix tableC1 = J(2,6,.)
forvalues c=1/6{
mat tableC1[1,`c'] = `f1`c''
mat tableC1[2,`c'] = `f2`c''
}
local colnames france_mean egalit_mean egalit_sd inegalit_mean inegalit_sd diff_pval
local rownames End_first_phase_DT End_DT
matrix colnames tableC1 = `colnames'
matrix rownames tableC1 = `rownames'
mat list tableC1
esttab matrix(tableC1, fmt(2)), mlabel("Appendix Table C1")
esttab matrix(tableC1, fmt(2)) using "$APPTAB/tableC1.tex", mlabel("Appendix Table C1") replace
* ==============================================================================


********************************************************************************
*
* APPENDIX D. DIFF-IN-DIFF ROBUSTNESS CHECKS
*
********************************************************************************


* ==============================================================================
* Table D1. Placebo test.
* ------------------------------------------------------------------------------
use "$DAT/final-henry.dta", clear

* Last cohort who had last child before 1793
bys byear: egen maxlbyear = max(lbyear)
tab byear, summ(maxlbyear)
	// the 1739-cohort is the last cohort to have their last child before the reforms

* Placebo regressions
* -------------------
local py = 1739
* placebo sample (103 cohorts)
keep if byear>=`py'-103 & byear<=`py'
* placebo reform
local placeboref = `py'-10
* placebo treatment
local fage = 40
local tage = 40-15
gen Tplacebo = 0 if `placeboref'-byear>40
forvalues i=0/`tage'{
replace Tplacebo = `i' if `placeboref'-byear==40-`i'
}
replace Tplacebo = `tage' if `placeboref'-byear<15
replace Tplacebo = .  if byear==.
gen TplaceboXaffected = Tplacebo*affected
gen T01placeboXaffected = (TplaceboXaffected>0)
replace T01placeboXaffected = . if TplaceboXaffected==.
label var TplaceboXaffected "Reformed inheritance $\times$ Fertile post-placebo reform"
* placebo regressions
global flextrends prewheat ldensity_1793 vidxcivil ldist_eveche ldist_socpol ldist_rebellion_state_1779_1789 ldist_bailliage ldist_subdeleg ldist_recette ldist_cassini ldist_post
reghdfe nfert T01placeboXaffected , absorb(byear villagenum) cluster(villagenum)
outreg2 using "$APPTAB/tableD1.tex", ///
	keep(T01placeboXaffected) nocons ///
	title("Dep. var.: net completed fertility") ctitle(" ") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, ., Flexible trends, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long replace
reghdfe nfert T01placeboXaffected i.SI_MA_FE, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE) cluster(villagenum)
outreg2 using "$APPTAB/tableD1.tex", ///
	keep(T01placeboXaffected) nocons ///
	title("Dep. var.: net completed fertility") ctitle(" ") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
reghdfe nfert T01placeboXaffected i.SI_MA_FE, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableD1.tex", ///
	keep(T01placeboXaffected) nocons ///
	title("Dep. var.: net completed fertility") ctitle(" ") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
* ==============================================================================


* ==============================================================================
* Table D2: Alternative definitions of sample, exposure, and treatment group.
* ------------------------------------------------------------------------------
use "$DAT/final-henry.dta", clear

* Sample
keep if byear>=1700 // born after 1700
qui xi: reghdfe nfert T01xaffected, absorb(byear) cluster(villagenum)
keep if e(sample)==1 // reg non-missing values

* Regressions
label var T01xaffected "Reform $\times$ Fertile"
global flextrends prewheat ldensity_1793 vidxcivil ldist_eveche ldist_socpol ldist_rebellion_state_1779_1789 ldist_bailliage ldist_subdeleg ldist_recette ldist_cassini ldist_post

* Panel A: Sample years (1720-1780)
* --------------------------------------
preserve
keep if byear>=1720 & byear<=1780
// base specification
qui reghdfe nfert T01xaffected , absorb(byear villagenum ) cluster(villagenum)
outreg2 using "$APPTAB/tableD2-panelA.tex", ///
	keep(T01xaffected ) nocons ///
	title("Dep. Variable: Completed fertility") ctitle(" ") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, ., Flexible trends, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long replace
// individual-level controls
qui reghdfe nfert T01xaffected i.SI_MA_FE, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE) cluster(villagenum)
outreg2 using "$APPTAB/tableD2-panelA.tex", ///
	keep(T01xaffected ) nocons ///
	title("Dep. Variable: Completed fertility") ctitle(" ") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
// full-specification
qui reghdfe nfert T01xaffected i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableD2-panelA.tex", ///
	keep(T01xaffected ) nocons ///
	title("Dep. Variable: Completed fertility") ctitle(" ") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
restore

* Panel B. Alternative exposure based on 30-year reproductive span (ages 15–45)
* ----------------------------------------------------------------------------
* define alternative exposure measure:
preserve
gen T01alt = (byear>=1749)
replace T01alt = . if byear==.
gen T01xaffected_alt = affected*T01alt
* regressions
// base specification
qui reghdfe nfert T01xaffected_alt , absorb(byear villagenum ) cluster(villagenum)
outreg2 using "$APPTAB/tableD2-panelB.tex", ///
	keep(T01xaffected_alt ) nocons ///
	title("Dep. Variable: Completed fertility") ctitle(" ") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, ., Flexible trends, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long replace
// individual-level controls
qui reghdfe nfert T01xaffected_alt i.SI_MA_FE, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE) cluster(villagenum)
outreg2 using "$APPTAB/tableD2-panelB.tex", ///
	keep(T01xaffected_alt ) nocons ///
	title("Dep. Variable: Completed fertility") ctitle(" ") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
// full-specification
qui reghdfe nfert T01xaffected_alt i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableD2-panelB.tex", ///
	keep(T01xaffected_alt ) nocons ///
	title("Dep. Variable: Completed fertility") ctitle(" ") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
restore

* Panel C. Alternative exposure based on 15-year reproductive span (ages 15–30)
* ----------------------------------------------------------------------------
* regressions
preserve
gen T01alt = (byear>=1764)
replace T01alt = . if byear==.
gen T01xaffected_alt = affected*T01alt
// base specification
qui reghdfe nfert T01xaffected_alt , absorb(byear villagenum ) cluster(villagenum)
outreg2 using "$APPTAB/tableD2-panelC.tex", ///
	keep(T01xaffected_alt ) nocons ///
	title("Dep. Variable: Completed fertility") ctitle(" ") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, ., Flexible trends, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long replace
// individual-level controls
qui reghdfe nfert T01xaffected_alt i.SI_MA_FE, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE) cluster(villagenum)
outreg2 using "$APPTAB/tableD2-panelC.tex", ///
	keep(T01xaffected_alt ) nocons ///
	title("Dep. Variable: Completed fertility") ctitle(" ") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
// full-specification
qui reghdfe nfert T01xaffected_alt i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableD2-panelC.tex", ///
	keep(T01xaffected_alt ) nocons ///
	title("Dep. Variable: Completed fertility") ctitle(" ") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
restore

* Panel D. Full treatment (abolishing impartible inheritance and including women)
* ----------------------------------------------------------------------------
preserve
gen affected2 = 1 if impart==1 & womexc==1
replace affected2 = 0 if impart==0 & womexc==0
gen T01xaffected2 = T01*affected2
// base specification
qui reghdfe nfert T01xaffected2 , absorb(byear villagenum ) cluster(villagenum)
outreg2 using "$APPTAB/tableD2-panelD.tex", ///
	keep(T01xaffected2 ) nocons ///
	title("Dep. Variable: Completed fertility") ctitle(" ") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, ., Flexible trends, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long replace
// individual-level controls
qui reghdfe nfert T01xaffected2 i.SI_MA_FE, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE) cluster(villagenum)
outreg2 using "$APPTAB/tableD2-panelD.tex", ///
	keep(T01xaffected2 ) nocons ///
	title("Dep. Variable: Completed fertility") ctitle(" ") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
// full-specification
qui reghdfe nfert T01xaffected2 i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableD2-panelD.tex", ///
	keep(T01xaffected2 ) nocons ///
	title("Dep. Variable: Completed fertility") ctitle(" ") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
restore
* ==============================================================================


* ==============================================================================
* Table D3: Effects of abolishing impartible inheritance.
* Table D4: Effects of including women in inheritances.
* ------------------------------------------------------------------------------
use "$DAT/final-henry.dta", clear

* Sample
keep if byear>=1700 // born after 1700
qui xi: reghdfe nfert T01xaffected, absorb(byear) cluster(villagenum)
keep if e(sample)==1 // reg non-missing values

* Regressions
global flextrends prewheat ldensity_1793 vidxcivil ldist_eveche ldist_socpol ldist_rebellion_state_1779_1789 ldist_bailliage ldist_subdeleg ldist_recette ldist_cassini ldist_post
local x1 "Dep. var.: age at marriage"
local x2 "Dep. var. = 1 if childless"
local x3 "Dep. var.: completed fertility"
local panels="A B C"

local j=3
foreach v in impart womexc{

global treatvar i.T01##i.`v'
global treatvar1 1.T01##1.`v'
****qui xi: reghdfe nfert $treatvars, absorb(byear) cluster(villagenum)
****keep if e(sample)==1

local i=1
foreach x in nfert chdls mage{
local pan `: word `i' of `panels''
// no controls
qui reghdfe `x' $treatvar , absorb(byear villagenum) cluster(villagenum)
outreg2 using "$APPTAB/tableD`j'-panel`pan'.tex", ///
	keep($treatvar1 ) nocons ///
	title("`x`i''") ctitle("`x'") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, ., Flexible trends, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long replace
// + individual-level controls
qui reghdfe `x' $treatvar i.SI_MA_FE, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE) cluster(villagenum)
outreg2 using "$APPTAB/tableD`j'-panel`pan'.tex", ///
	keep($treatvar1 ) nocons ///
	title("`x`i''") ctitle("`x'") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
// + flexible-trends
qui reghdfe `x' $treatvar i.SI_MA_FE i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableD`j'-panel`pan'.tex", ///
	keep($treatvar1 ) nocons ///
	title("`x`i''") ctitle("`x'") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
local i = `i'+1
}
local j = `j'+1
}
* ==============================================================================


* ==============================================================================
* Table D5: Robustness to migration and changes in mortality.
* ------------------------------------------------------------------------------
use "$DAT/final-henry.dta", clear

* Sample
keep if byear>=1700 // born after 1700
qui xi: reghdfe nfert T01xaffected, absorb(byear) cluster(villagenum)
keep if e(sample)==1 // reg non-missing values

* Regressions
label var T01xaffected "Reform $\times$ Fertile"
global flextrends prewheat ldensity_1793 vidxcivil ldist_eveche ldist_socpol ldist_rebellion_state_1779_1789 ldist_bailliage ldist_subdeleg ldist_recette ldist_cassini ldist_post

// baseline
qui reghdfe nfert T01xaffected i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableD5.tex", ///
	keep(T01xaffected) nocons ///
	title("Dep. variable: completed fertility") ctitle("baseline sample") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Avg longevity in decade-municipality, ., Avg prob of women dying <40 in decade-municipality, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long replace

// + sample: women completed fertility cycle
qui reghdfe nfert T01xaffected i.SI_MA_FE logpwheat if dage>=40, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableD5.tex", ///
	keep(T01xaffected) nocons ///
	title("Dep. variable: completed fertility") ctitle("women$>$40") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Avg longevity in decade-municipality, ., Avg prob of women dying <40 in decade-municipality, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
	
// + sample: spouses completed fertility cycle
qui reghdfe nfert T01xaffected i.SI_MA_FE logpwheat if dage>=40 & sdage>=40, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableD5.tex", ///
	keep(T01xaffected) nocons ///
	title("Dep. variable: completed fertility") ctitle("spouses$>$40") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Avg longevity in decade-municipality, ., Avg prob of women dying <40 in decade-municipality, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long

// + average women's longevity (by village, decade)
qui reghdfe nfert T01xaffected i.SI_MA_FE logpwheat avlong if dage>=40 & sdage>=40, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableD5.tex", ///
	keep(T01xaffected) nocons ///
	title("Dep. variable: completed fertility") ctitle("spouses$>$40") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Avg longevity in decade-municipality, Y, Avg prob of women dying <40 in decade-municipality, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long

// + probability women died before 40 (by village, decade)
qui reghdfe nfert T01xaffected i.SI_MA_FE logpwheat avlong prob40 if dage>=40 & sdage>=40, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableD5.tex", ///
	keep(T01xaffected) nocons ///
	title("Dep. variable: completed fertility") ctitle("spouses$>$40") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Avg longevity in decade-municipality, Y, Avg prob of women dying <40 in decade-municipality, Y) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
* ==============================================================================


* ==============================================================================
* Table D6: Adjusted fertility using the first-name repetition technique.
* ------------------------------------------------------------------------------
use "$DAT/final-henry.dta", clear

* Sample
keep if byear>=1700 // born after 1700
qui xi: reghdfe nfert T01xaffected, absorb(byear) cluster(villagenum)
keep if e(sample)==1 // reg non-missing values

* Regressions
label var T01xaffected "Reform $\times$ Fertile"
global flextrends prewheat ldensity_1793 vidxcivil ldist_eveche ldist_socpol ldist_rebellion_state_1779_1789 ldist_bailliage ldist_subdeleg ldist_recette ldist_cassini ldist_post

local i = 1
local panels="A B C"

foreach y in nfert_adj intmargadj chdlsadj{

local pan `: word `i' of `panels''

// base specification
qui reghdfe `y' T01xaffected , absorb(byear villagenum ) cluster(villagenum)
outreg2 using "$APPTAB/tableD6-panel`pan'.tex", ///
	keep(T01xaffected ) nocons ///
	title("Dep. Variable adjusted using first-name technique") ctitle("`y'") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, ., Flexible trends, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long replace
// individual-level controls
qui reghdfe `y' T01xaffected i.SI_MA_FE, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE) cluster(villagenum)
outreg2 using "$APPTAB/tableD6-panel`pan'.tex", ///
	keep(T01xaffected ) nocons ///
	title("Dep. Variable adjusted using first-name technique") ctitle("`y'") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
// full-specification
qui reghdfe `y' T01xaffected i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableD6-panel`pan'.tex", ///
	keep(T01xaffected ) nocons ///
	title("Dep. Variable adjusted using first-name technique") ctitle("`y'") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long

local i = `i'+1
}
* ==============================================================================



* ==============================================================================
* Table D7: Robustness controlling for soil, climate, and terrain characteristics.
* ------------------------------------------------------------------------------
use "$DAT/final-henry.dta", clear

* Sample
keep if byear>=1700 // born after 1700
qui xi: reghdfe nfert T01xaffected, absorb(byear) cluster(villagenum)
keep if e(sample)==1 // reg non-missing values

* Regressions
label var T01xaffected "Reform $\times$ Fertile"
global flextrends prewheat ldensity_1793 vidxcivil ldist_eveche ldist_socpol ldist_rebellion_state_1779_1789 ldist_bailliage ldist_subdeleg ldist_recette ldist_cassini ldist_post

* Panel A: 
* controlling for caloric suitability
* -----------------------------------
// baseline specification
qui reghdfe nfert T01xaffected i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableD7-panelA.tex", ///
	keep(T01xaffected) nocons ///
	title("`x`i''") ctitle("CF") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Caloric suitability of land, ., Caloric suitability of land $\times$ Cohort FE, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long replace
// caloric suitability (trends)
qui reghdfe nfert T01xaffected i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends avcalmean)#byear ) cluster(villagenum)
outreg2 using "$APPTAB/tableD7-panelA.tex", ///
	keep(T01xaffected) nocons ///
	title("`x`i''") ctitle("CF") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Caloric suitability of land, Y, Caloric suitability of land $\times$ Cohort FE, Y) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
// caloric suitability (trends) + sample restriction
qui reghdfe nfert T01xaffected i.SI_MA_FE logpwheat if ruggedness<3, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends avcalmean)#byear ) cluster(villagenum)
outreg2 using "$APPTAB/tableD7-panelA.tex", ///
	keep(T01xaffected) nocons ///
	title("`x`i''") ctitle("CF") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Caloric suitability of land, Y, Caloric suitability of land $\times$ Cohort FE, Y) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long

* Panel B: 
* controlling for ruggedness
* -----------------------------------
// baseline specification
qui reghdfe nfert T01xaffected i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableD7-panelB.tex", ///
	keep(T01xaffected) nocons ///
	title("`x`i''") ctitle("CF") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Terrain ruggedness, ., Terrain ruggedness $\times$ Cohort FE, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long replace
// ruggedness (trends)
qui reghdfe nfert T01xaffected i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends ruggedness)#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableD7-panelB.tex", ///
	keep(T01xaffected) nocons ///
	title("`x`i''") ctitle("CF") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Terrain ruggedness, Y, Terrain ruggedness $\times$ Cohort FE, Y) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
// caloric suitability (trends) + sample restriction
qui reghdfe nfert T01xaffected i.SI_MA_FE logpwheat if ruggedness<3, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends ruggedness)#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableD7-panelB.tex", ///
	keep(T01xaffected) nocons ///
	title("`x`i''") ctitle("CF") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Terrain ruggedness, Y, Terrain ruggedness $\times$ Cohort FE, Y) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long

* Panel C: 
* controlling for sandy soils
* -----------------------------------
* impute Rosny's share of sandy soils (missing)
// Note: Rosny has an imputed texture of 4 (soil type fine), so we impute the sample minimum share of sandy soils
summ sh_sandy, d
replace sh_sandy = `r(min)' if insee_com=="93064" & sh_sandy==.
// baseline specification
qui reghdfe nfert T01xaffected i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableD7-panelC.tex", ///
	keep(T01xaffected) nocons ///
	title("`x`i''") ctitle("CF") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Caloric suitability of land, ., Caloric suitability of land $\times$ Cohort FE, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long replace
// soil texture (trends)
qui reghdfe nfert T01xaffected i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends sh_sandy)#byear ) cluster(villagenum)
outreg2 using "$APPTAB/tableD7-panelC.tex", ///
	keep(T01xaffected) nocons ///
	title("`x`i''") ctitle("CF") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Caloric suitability of land, Y, Caloric suitability of land $\times$ Cohort FE, Y) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
// soil texture (trends) + sample restriction
qui reghdfe nfert T01xaffected i.SI_MA_FE logpwheat if ruggedness<3, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends sh_sandy)#byear ) cluster(villagenum)
outreg2 using "$APPTAB/tableD7-panelC.tex", ///
	keep(T01xaffected) nocons ///
	title("`x`i''") ctitle("CF") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Caloric suitability of land, Y, Caloric suitability of land $\times$ Cohort FE, Y) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long

* Panel D: 
* controlling for both
* -----------------------------------

// baseline specification
qui reghdfe nfert T01xaffected i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableD7-panelD.tex", ///
	keep(T01xaffected) nocons ///
	title("`x`i''") ctitle("CF") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Caloric suitability of land, ., Terrain ruggedness, ., Caloric suitability of land $\times$ Cohort FE, ., Terrain ruggedness $\times$ Cohort FE, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long replace
// caloric suitability, ruggedness, and soil texture (trends)
qui reghdfe nfert T01xaffected i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends avcalmean ruggedness sh_sandy)#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableD7-panelD.tex", ///
	keep(T01xaffected) nocons ///
	title("`x`i''") ctitle("CF") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Caloric suitability of land, Y, Terrain ruggedness, Y, Caloric suitability of land $\times$ Cohort FE, Y, Terrain ruggedness $\times$ Cohort FE, Y) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
// caloric suitability, ruggedness, and soil texture (trends) + sample restriction
qui reghdfe nfert T01xaffected i.SI_MA_FE logpwheat if ruggedness<3, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends avcalmean ruggedness sh_sandy)#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableD7-panelD.tex", ///
	keep(T01xaffected) nocons ///
	title("`x`i''") ctitle("CF") ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y, Caloric suitability of land, Y, Terrain ruggedness, Y, Caloric suitability of land $\times$ Cohort FE, Y, Terrain ruggedness $\times$ Cohort FE, Y) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
* ==============================================================================


* ==============================================================================
* Table D8: Robustness to excluding three outliers in Alps and Pyrenees with extreme ruggedness.
* ==============================================================================
use "$DAT/final-henry.dta", clear

* Sample
keep if byear>=1700 // born after 1700
qui xi: reghdfe nfert T01xaffected, absorb(byear) cluster(villagenum)
keep if e(sample)==1 // reg non-missing values
keep if ruggedness<3 // drop three outliers in Alps and Pyrenees with extreme ruggedness

* Regressions
label var T01xaffected "Reform $\times$ Fertile"
global flextrends prewheat ldensity_1793 vidxcivil ldist_eveche ldist_socpol ldist_rebellion_state_1779_1789 ldist_bailliage ldist_subdeleg ldist_recette ldist_cassini ldist_post

local i=1
local panels="A B C"

foreach y in nfert intmarg chdls{

local pan `: word `i' of `panels''

// baseline specification
reghdfe `y' T01xaffected , absorb(byear villagenum) cluster(villagenum)
outreg2 using "$APPTAB/tableD8-panel`pan'.tex", ///
	keep(T01xaffected) nocons ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, ., Flexible trends, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long replace
	
// individual controls
reghdfe `y' T01xaffected i.SI_MA_FE, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE ) cluster(villagenum)
outreg2 using "$APPTAB/tableD8-panel`pan'.tex", ///
	keep(T01xaffected) nocons ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, .) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
	
// flexible trends
reghdfe `y' T01xaffected i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
outreg2 using "$APPTAB/tableD8-panel`pan'.tex", ///
	keep(T01xaffected) nocons ///
	addtext(Cohort FE, Y, Municipality FE, Y, Individual-level controls, Y, Flexible trends, Y) ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long

local i = `i'+1
}
* ==============================================================================


* ==============================================================================
* Table D9: Alternative inference methods using the wild bootstrap procedure.
* ------------------------------------------------------------------------------
use "$DAT/final-henry.dta", clear

* Sample
keep if byear>=1700 // born after 1700
qui xi: reghdfe nfert T01xaffected, absorb(byear) cluster(villagenum)
keep if e(sample)==1 // reg non-missing values

* Regressions
label var T01xaffected "Reform $\times$ Fertile"
global flextrends prewheat ldensity_1793 vidxcivil ldist_eveche ldist_socpol ldist_rebellion_state_1779_1789 ldist_bailliage ldist_subdeleg ldist_recette ldist_cassini ldist_post
local x1 "Dep. var.: completed fertility"
local x2 "Dep. var.: completed fertility of mothers"
local x3 "Dep. var. = 1 if childless"
local x4 "Dep. var. = age at marriage"

set seed 4411284 // from random.org Min: 1, Max: 10000000 2025-04-10 18:30:21 UTC

local i=1
local panels="A B C"

foreach y in nfert intmarg chdls mage{

local pan `: word `i' of `panels''

// (1) no controls
wildbootstrap areg `y' i.villagenum T01xaffected , absorb(byear) cluster(villagenum) coef(T01xaffected )
local wildpvalue = e(wboot)[1,3]
xi: reghdfe `y' T01xaffected , absorb(byear villagenum) cluster(villagenum)
local nobs = `e(N)'
outreg2 using "$APPTAB/tableD9-panel`pan'.tex", ///
	keep(T01xaffected ) nocons noobs nor2 ///
	title("`x`i''") ctitle("`y'") ///
	addtext(Wild pvalue, `wildpvalue', Cohort FE, Y, Municipality FE, Y, Individual level controls, ., Flexible trends, ., N, `nobs') /// ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long replace
// (2) individual-level controls
wildbootstrap areg `y' i.SI_MA_FE i.TYP_FICH i.SU_PE_FE i.SU_ME_FE i.villagenum T01xaffected , absorb(byear) cluster(villagenum) coef(T01xaffected )
local wildpvalue = e(wboot)[1,3]
xi: reghdfe `y' T01xaffected i.SI_MA_FE, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE) cluster(villagenum)
local nobs = `e(N)'
outreg2 using "$APPTAB/tableD9-panel`pan'.tex", ///
	keep(T01xaffected ) nocons noobs nor2 ///
	title("`x`i''") ctitle("`y'") ///
	addtext(Wild pvalue, `wildpvalue', Cohort FE, Y, Municipality FE, Y, Individual level controls, Y, Flexible trends, ., N, `nobs') /// ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long
// (3) flexible trends
wildbootstrap areg `y' i.SI_MA_FE i.TYP_FICH i.SU_PE_FE i.SU_ME_FE c.prewheat#byear c.ldensity_1793#byear c.vidxcivil#byear c.ldist_eveche#byear c.ldist_socpol#byear c.ldist_rebellion_state_1779_1789#byear c.ldist_bailliage#byear c.ldist_subdeleg#byear c.ldist_recette#byear c.ldist_cassini#byear c.ldist_post#byear i.villagenum T01xaffected , absorb(byear) cluster(villagenum) coef(T01xaffected )
local wildpvalue = e(wboot)[1,3]
reghdfe `y' T01xaffected i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
local nobs = `e(N)'
outreg2 using "$APPTAB/tableD9-panel`pan'.tex", ///
	keep(T01xaffected ) nocons noobs nor2 ///
	title("`x`i''") ctitle("`y'") ///
	addtext(Wild pvalue, `wildpvalue', Cohort FE, Y, Municipality FE, Y, Individual level controls, Y, Flexible trends, Y, N, `nobs') /// ///
	addstat(N clusters, `e(N_clust)') adjr2 nonotes addnote(SE clustered by village, *p<.05; **p<.01; ***p<.001) ///
	label dec(3) adec(0) tex(fragment) long

local i = `i'+1
}	
* ==============================================================================


* ==============================================================================
* Figure D1: Permutation tests.
* ------------------------------------------------------------------------------
use "$DAT/final-henry.dta", clear

* seed for replicability 25374609 from random.org (2022-05-26, 08:52:30 UTC)
set more off
gen identity = _n

* Sample and vars
keep if byear>=1700
keep nfert affected T01xaffected T01 SI_MA_FE logpwheat byear TYP_FICH vidxcivil SU_PE_FE SU_ME_FE villagenum ldist_eveche ldist_bailliage ldist_subdeleg ldist_recette ldist_socpol ldist_rebellion_all_1779_1789 ldist_rebellion_state_1779_1789 ldist_cassini ldist_post prewheat ldensity_1793 pw1*
rename ldist_rebellion_state_1779_1789 ldist_reb
global flextrends = "prewheat ldensity_1793 vidxcivil ldist_eveche ldist_socpol ldist_reb ldist_bailliage ldist_subdeleg ldist_recette ldist_cassini ldist_post"

* Baseline coefficients
reghdfe nfert 1.affected#1.T01 SI_MA_FE, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE) cluster(villagenum)
global base0afe = _b[1.affected#1.T01]

* Baseline coefficients
reghdfe nfert 1.affected#1.T01 SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
global base1afe = _b[1.affected#1.T01]

* TEST 1: permute "inheritance system" across municipalities, DD
* ------------------------------------------------------------------------------
* unmark and run only once
xi: ritest affected _b[1.T01#1.affected], saving("$TEMP/temp-statabc-permute-test1.dta", replace) reps(10000) seed(25374609) cluster(villagenum): reghdfe nfert 1.T01#1.affected SI_MA_FE, nocons absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE) cl(villagenum)

* TEST 2: permute "inheritance system" across municipalities, DD + flex trends
* ------------------------------------------------------------------------------
* unmark and run only once
xi: ritest affected _b[1.T01#1.affected], saving("$TEMP/temp-statabc-permute-test2.dta", replace) reps(10000) seed(25374609) cluster(villagenum): reghdfe nfert 1.T01#1.affected SI_MA_FE logpwheat, nocons absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cl(villagenum)


* TEST 3: permute "inheritance system" together with vector of flex trends across 
* municipalities, DD + flex trends
* ------------------------------------------------------------------------------
* unmark and run only once
*
use "$DAT/final-henry.dta", clear
* Set seed for replicability
set seed 25374609		// from random.org (2022-05-26, 08:52:30 UTC)
set more off
gen identity = _n
* Sample and vars
keep if byear>=1700
keep nfert affected T01xaffected T01 SI_MA_FE logpwheat byear TYP_FICH vidxcivil SU_PE_FE SU_ME_FE villagenum ldist_eveche ldist_bailliage ldist_subdeleg ldist_recette ldist_socpol ldist_rebellion_all_1779_1789 ldist_rebellion_state_1779_1789 ldist_cassini ldist_post prewheat ldensity_1793 pw1*
rename ldist_rebellion_state_1779_1789 ldist_reb
* Baseline coefficients
reghdfe nfert c.affected#c.T01 i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.(prewheat ldensity_1793 vidxcivil ldist_eveche ldist_socpol ldist_reb ldist_bailliage ldist_subdeleg ldist_recette ldist_cassini ldist_post)#byear) cluster(villagenum)
global base1afe = _b[c.affected#c.T01]
* Decades at which women turned 15 (for wheat price var)
gen year15 = byear+15
gen decade15 = 1 if year15>=1710 & year15<=1719
local i = 1
forvalues t=1720(10)1790{
local t2=`t'+9
replace decade15 = `i' if year15>=`t' & year15<=`t2'
local i = `i'+1
}
replace decade15 = `i' if year15>=1790 & year15!=.
* Save working sample
keep if e(sample)==1
gen decade = 10 * floor(byear+15/10)
tempfile sample
save `sample'

* Permutation loop
local replace "replace"
global boots = 10000
forvalues i = 1(1)$boots{
qui {
use `sample', clear

* reshuffle municipalities within decade at which women turned 15
collapse affected vidxcivil ldist_eveche ldist_bailliage ldist_subdeleg ldist_recette ldist_socpol ldist_reb ldist_cassini ldist_post prewheat ldensity_1793 logpwheat, by(villagenum decade15)
duplicates drop
bys decade15: gen num = _n
bys decade15: gen u = rnormal()
sort decade15 u
foreach vp in affected vidxcivil ldist_eveche ldist_bailliage ldist_subdeleg ldist_recette ldist_socpol ldist_reb ldist_cassini ldist_post prewheat ldensity_1793 logpwheat{
by decade15: gen `vp'_prmt = `vp'[num]
}
drop num u
* merge with working sample 
format villagenum %10.0g
merge 1:m villagenum decade15 using `sample', nogen

* Estimate from permutation
reghdfe nfert c.affected_prmt#c.T01 logpwheat_prmt, absorb(byear villagenum SI_MA_FE TYP_FICH SU_PE_FE SU_ME_FE c.(prewheat_prmt ldensity_1793_prmt vidxcivil_prmt ldist_eveche_prmt ldist_socpol_prmt ldist_reb_prmt ldist_bailliage_prmt ldist_subdeleg_prmt ldist_recette_prmt ldist_cassini_prmt ldist_post_prmt)#byear) cluster(villagenum)
gen coef2_afe = _b[c.affected_prmt#c.T01]

* store estimation results
collapse coef2_afe
if `i'==1{
save "$TEMP/temp-permute-test3.dta", replace
}
if `i'>1{
append using "$TEMP/temp-permute-test3.dta"
save "$TEMP/temp-permute-test3.dta", replace
}
local j = round(`i',10)
}
di "`i'"
}
*/

* Plot results
* ------------------------------------------------------------------------------
use "$DAT/final-henry.dta", clear
keep if byear>=1700
global flextrends = "prewheat ldensity_1793 vidxcivil ldist_eveche ldist_socpol ldist_rebellion_state_1779_1789 ldist_bailliage ldist_subdeleg ldist_recette ldist_cassini ldist_post"

* Baseline coefficients
reghdfe nfert 1.affected#1.T01 SI_MA_FE, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE) cluster(villagenum)
global base0afe = _b[1.affected#1.T01]
reghdfe nfert 1.affected#1.T01 SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
global base1afe = _b[1.affected#1.T01]

* PANEL A	
use "$TEMP/temp-statabc-permute-test1.dta", clear
count
global reps = `r(N)'
count if _pm_1 < $base0afe
	// because coefs are negative!
local plarger = `r(N)'/$reps
hist _pm_1, xline($base0afe ) xlabel(-1.0(0.2)1.0) ///
	xtitle("Coefficient on Reformed inheritance × Fertile post-reform") ///
	bin(100) note("Share larger magnitude = 0`plarger'") ///
	fc(stc1) lc(none) lwidth(zero) scale(1.6) name(b1, replace)
graph export "$APPFIG/figureD1a.pdf", as(pdf) name("b1") replace

* PANEL B
use "$TEMP/temp-statabc-permute-test2.dta", clear
count
global reps = `r(N)'
count if _pm_1 < $base1afe
	// because coefs are negative!
local plarger = `r(N)'/$reps
hist _pm_1, xline($base1afe ) xlabel(-1.0(0.2)1.0) ///
	xtitle("Coefficient on Reformed inheritance × Fertile post-reform") ///
	bin(100) note("Share larger magnitude = 0`plarger'") ///
	fc(stc1) lc(none) lwidth(zero) scale(1.6) name(b2, replace)
graph export "$APPFIG/figureD1b.pdf", as(pdf) name("b2") replace

* PANEL C
use "$TEMP/temp-permute-test3.dta", clear
count
global reps = `r(N)'
count if coef2_afe < $base1afe
	// because coefs are negative!
local plarger = `r(N)'/$reps
hist coef2_afe, xline($base1afe ) xlabel(-1.0(0.2)1.0) ///
	xtitle("Coefficient on Reformed inheritance × Fertile post-reform") ///
	ylabel(0(0.5)3) bin(100) note("Share larger magnitude = 0`plarger'") ///
	fc(stc1) lc(none) lwidth(zero) scale(1.6) name(b3, replace)
graph export "$APPFIG/figureD1c.pdf", as(pdf) name("b3") replace
* ==============================================================================



* ==============================================================================
* Figure D2. Sensitivity of main estimates to outliers
* ------------------------------------------------------------------------------
use "$DAT/final-henry.dta", clear
keep if byear>=1700
global flextrends = "prewheat ldensity_1793 vidxcivil ldist_eveche ldist_socpol ldist_rebellion_state_1779_1789 ldist_bailliage ldist_subdeleg ldist_recette ldist_cassini ldist_post"

* Baseline coefficients
xi: reghdfe nfert T01xaffected i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
estimates store coef_base
keep if e(sample)==1
encode villagename, gen(nvillagenum)
label val nvillagenum

* Sensitivity coefficients
forvalues m=1/39{
preserve
drop if nvillagenum==`m'
xi: reghdfe nfert T01xaffected i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
estimates store coef_`m'
restore
}
coefplot (coef_base, mcolor(blue) ciopts(lw(thick) lcolor(blue))) coef_1 coef_2 coef_3 coef_4 coef_5 coef_6 coef_7 coef_8 coef_9 coef_10 ///
coef_11 coef_12 coef_13 coef_14 coef_15 coef_16 coef_17 coef_18 coef_19 coef_20 ///
coef_21 coef_22 coef_23 coef_24 coef_25 coef_26 coef_27 coef_28 coef_29 coef_30 ///
coef_31 coef_32 coef_33 coef_34 coef_35 coef_36 coef_37 coef_38 coef_39 ///
, keep(T01xaffected) vert graphregion(fc(white) lc(white)) ///
	legend(on order(2 "Baseline" 4 "Excluding one municipality" 5 "95% CI") rows(1) size(medlarge) pos(7) ring(1)) ///
	xlabel(0.45 " " 1.55 " ") ylabel(-0.9(0.1)0.1) ytitle(" ") title("Coefficient on Reformed inheritance" "× Fertile post-reform", color(black)) ///
	mcolor(gs11) ciopts(lcolor(gs11)) yline(0, lcolor(black) lpattern(dash))
graph export "$APPFIG/figureD2.pdf", as(pdf) name("Graph") replace
* ==============================================================================


* ==============================================================================
* Figure D3. Baseline vs. placebo exercises
* ------------------------------------------------------------------------------
use "$DAT/final-henry.dta", clear

* Last cohort who had last child before 1793
bys byear: egen maxlbyear = max(lbyear)
tab byear, summ(maxlbyear)
	// the 1739-cohort is the last cohort to have their last child before the reforms

* Placebo figure
local py = 1739
local py0 = `py'-103
local fage = 40
local tage = 40-15
local placeboref = `py'-10
local ysincetrueref = 1793-`placeboref'
gen Tplacebo = 0 if `placeboref'-byear>40
forvalues i=0/`tage'{
replace Tplacebo = `i' if `placeboref'-byear==40-`i'
}
replace Tplacebo = `tage' if `placeboref'-byear<15
replace Tplacebo = .  if byear==. | (byear>`py' | byear<`py'-103)
replace T = . if byear<1700
keep if byear>1625
local midp = `py0'+50
sort byear
twoway (line T byear, lc(gray%50) lw(vthick)) ///
(pcarrowi -5 1700 -5 1803 (1), lcolor(gray) mc(gray) recast(pcbarrow)), ///
text(-5 1750 "sample", place(n) color(gray) size(small)) ///
xline(1700, lp(dash) lc(gray)) xline(1803, lp(dash) lc(gray)) ///
xlabel(1625(25)1812) ///
ylabel(-5 " " 0 "0" 5 "5" 10 "10" 15 "15" 20 "20" 25 "25") ///
title("Exposure for 1793 reform", color(black)) ytitle("Years fertile" "post-1793 reform") xtitle("cohort") ///
legend(off) graphregion(fc(white) lc(white)) name(true, replace)
*
twoway (line Tplacebo byear, lc(cranberry%50) lw(vthick)) ///
(pcarrowi -5 `py0' -5 `py' (1), lcolor(cranberry) mc(cranberry) recast(pcbarrow)), ///
text(-5 `midp' "placebo sample", place(n) color(cranberry) size(small)) ///
xline(`py0', lp(dash) lc(cranberry)) xline(`py', lp(dash) lc(cranberry)) ///
xlabel(1625(25)1812) ///
ylabel(-5 " " 0 "0" 5 "5" 10 "10" 15 "15" 20 "20" 25 "25") ///
title("Exposure for placebo reform", color(black)) ytitle("Years fertile" "post-placebo reform") xtitle("cohort") ///
legend(off) graphregion(fc(white) lc(white)) name(placebo, replace)
graph combine true placebo, rows(2) graphregion(fc(white) lc(white))
graph export "$APPFIG/figureD3.pdf", as(pdf) name("Graph") replace
graph drop _all
* ==============================================================================


* ==============================================================================
* Figure D4. Alternative definitions of treatment.
* ------------------------------------------------------------------------------
use "$DAT/final-henry.dta", clear
keep if byear>=1700
local fage = 45
local tage = `fage'-15
gen Talt = 0 if 1793-byear>`fage'
forvalues i=0/`tage'{
replace Talt = `i' if 1793-byear==`fage'-`i'
}
replace Talt = `tage' if 1793-byear<15
replace Talt = .  if byear==.
*
local fage = 30
local tage = `fage'-15
gen Talt2 = 0 if 1793-byear>`fage'
forvalues i=0/`tage'{
replace Talt2 = `i' if 1793-byear==`fage'-`i'
}
replace Talt2 = `tage' if 1793-byear<15
replace Talt2 = .  if byear==.
*
sort byear
label var byear "Cohort"
twoway 	(line T byear, lw(thick) lc(blue%50)) ///
		(line Talt2 byear, lw(thick) lc(gray%50)) ///
		(line Talt byear, lpattern(dash) lw(thick) lc(gray%50)) ///
		, ytitle(Years fertile post-reform) ylabel(0(5)30) xlabel(1700(10)1800) graphregion(fcolor(white)) ///
legend(on rows(3) order(1 "Baseline treatment" 2 "Alternative treatment (15-30 fertile cycle)" 3 "Alternative treatment (15-45 fertile cycle)") ring(0) position(11) nobox region(lstyle(none)))
graph export "$APPFIG/figureD4.pdf", as(pdf) name("Graph") replace
graph drop _all
* ==============================================================================


* ==============================================================================
* Figure D5: Conley adjusted standard errors with different distance cutoffs.
* ==============================================================================

* CONLEY S.E. FOR BASELINE DD
* ---------------------------
clear all
set maxvar 32767
use "$DAT/final-henry.dta", clear

* Sample
keep if byear>=1700 // born after 1700
qui xi: reghdfe nfert T01xaffected, absorb(byear) cluster(villagenum)
keep if e(sample)==1 // reg non-missing values

* Unabsorbed FE
tab TYP_FICH, gen(TYP_)
tab SU_PE_FE, gen(SUP_) 
tab SU_ME_FE, gen(SUM_)
global indco TYP_2 TYP_3 TYP_4 TYP_5 TYP_6 TYP_7 TYP_8 SUP_2 SUP_3 SUP_4 SUP_5 SUP_6 SUM_2 SUM_3 SUM_5

* S.E. clustered by municipality
reghdfe nfert T01xaffected SI_MA_FE, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE) cluster(villagenum)
keep if e(sample)==1
gen distcutoff = 0 if _n==1
gen conleyz = _b[T01xaffected]/_se[T01xaffected] if _n==1	

* Conley-adjusted SE, different cutoffs (over which spatial correlation assumed 0)
local n = 2
forvalues d=50(50)200{
di " ------------------------------ "
di " --------- cutoff `d' --------- "
di " ------------------------------ "
acreg nfert T01xaffected SI_MA_FE $indco , spatial latitude(latitude) longitude(longitude) pfe1(byear) pfe2(villagenum) id(villagenum) time(T01) lag(200) dist(`d')
replace distcutoff = `d' if _n==`n'
replace conleyz = _b[T01xaffected]/_se[T01xaffected] if _n==`n'
local n = `n'+1
}

* save data 
preserve 
keep distcutoff conleyz
keep if distcutoff!=.
save "$TEMP/DD_conley.dta", replace
restore 


* CONLEY S.E. FOR DD FLEXIBLE TRENDS
* ----------------------------------

clear all
set maxvar 32767
use "$DAT/final-henry.dta", clear
global flextrends prewheat ldensity_1793 vidxcivil ldist_eveche ldist_socpol ldist_rebellion_state_1779_1789 ldist_bailliage ldist_subdeleg ldist_recette ldist_cassini ldist_post

* Sample
keep if byear>=1700 // born after 1700
reghdfe nfert T01xaffected i.SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
keep if e(sample)==1 // reg non-missing values

* S.E. clustered by municipality
reghdfe nfert T01xaffected SI_MA_FE logpwheat, absorb(byear villagenum TYP_FICH SU_PE_FE SU_ME_FE c.($flextrends )#byear) cluster(villagenum)
keep if e(sample)==1
gen distcutoff = 0 if _n==1
gen conleyz = _b[T01xaffected]/_se[T01xaffected] if _n==1

* Partial-out higher-dimension FE & flexible trends
hdfe nfert T01xaffected logpwheat, clear absorb(byear villagenum SI_MA_FE TYP_FICH SU_PE_FE SU_ME_FE c.prewheat#byear c.ldensity_1793#byear c.vidxcivil#byear c.ldist_eveche#byear c.ldist_socpol#byear c.ldist_rebellion_state_1779_1789#byear c.ldist_bailliage#byear c.ldist_subdeleg#byear c.ldist_recette#byear c.ldist_cassini#byear c.ldist_post#byear) keepvars(byear villagenum latitude longitude distcutoff conleyz T01)

* Conley-adjusted SE, different cutoffs (over which spatial correlation assumed 0)
local n = 2
forvalues d=50(50)200{

di " ------------------------------ "
di " --------- cutoff `d' --------- "
di " ------------------------------ "
acreg nfert T01xaffected logpwheat , spatial latitude(latitude) longitude(longitude) id(villagenum) time(T01) lag(200) dist(`d')
replace distcutoff = `d' if _n==`n'
replace conleyz = _b[T01xaffected]/_se[T01xaffected] if _n==`n'
local n = `n'+1
}

* save data 
preserve 
keep distcutoff conleyz
keep if distcutoff!=.
save "$TEMP/DDflex_conley.dta", replace
restore 

* graph
preserve 
use "$TEMP/DD_conley.dta", clear
twoway (scatter conleyz distcutoff, msiz(medium)) (scatter conleyz distcutoff if distcutoff==0, msiz(medium)), ///
	xtitle(Distance cutoff) ytitle(Z (coef/s.e.)) ylabel(-5(1)0) ///
	xlabel(0(50)200) xmlabel(-10 " " 210 " ", notick) scale(1.5) ///
	yline(-1.645, lcolor(gs10)) ///
	legend(on order(2 "Baseline SE (clustered by municipality)" 1 "Conley-adjusted SE") rows(2) ring(0) pos(2) region(lc(black)) siz(medsmall)) name(a1, replace)
graph save "$APPFIG/figureD5a.gph", replace
graph export "$APPFIG/figureD5a.png", replace
restore
preserve 
use "$TEMP/DDflex_conley.dta", clear
twoway (scatter conleyz distcutoff, msiz(medium)) (scatter conleyz distcutoff if distcutoff==0, msiz(medium)), ///
	xtitle(Distance cutoff) ytitle(Z (coef/s.e.)) ylabel(-5(1)0) ///
	xlabel(0(50)200) xmlabel(-10 " " 210 " ", notick) scale(1.5) ///
	yline(-1.645, lcolor(gs10)) ///
	legend(on order(2 "Baseline SE (clustered by municipality)" 1 "Conley-adjusted SE") rows(2) ring(0) pos(2) region(lc(black)) siz(medsmall)) name(b1, replace)
graph export "$APPFIG/figureD5b.png", replace
restore
* ==============================================================================


********************************************************************************
*
* APPENDIX H. DATA APPENDIX
*
********************************************************************************


* ==============================================================================
* Figure H1: Lent and advent marriages between 1700 and 1815.
* ------------------------------------------------------------------------------
* Advent index and Lent index overtime
use "$DAT/final-henry.dta", clear
keep if AN_MA>=1700 & AN_MA<=1815 & MOIS_MA!=99 & JOUR_MA!=99
collapse idxlent idxadvent idxcivil, by(AN_MA)
twoway (scatter idxadvent AN_MA, msymbol(T)  msize(medsmall) mcolor(*0.5)) ///
	   (scatter idxlent   AN_MA, msymbol(Oh) msize(medsmall) mcolor(black)), ///
	   xtitle(" ") xlabel(1700(25)1775 1792 1815) xline(1792, lcolor(gray) lpattern(dash)) ///
	   ylabel(0(0.25)1.6) xtitle("marriage year") aspectratio(0.5) ///
	   legend(on order(1 "{it:r} = Advent" 2 "{it:r} = Lent") rows(2) ring(0) position(11) nobox region(lstyle(none))) ///
	   note(" ") graphregion(color(white) lc(white)) name(pA, replace)
graph export "$APPFIG/figureH1a.pdf", as(pdf) name("pA") replace
* Advent-Lent index by partible vs impartible inheritance
use "$DAT/final-henry.dta", clear
keep if AN_MA>=1700 & AN_MA<=1815 & MOIS_MA!=99 & JOUR_MA!=99
local yma = 2
keep if AN_MA>=1700
foreach x in idxlent idxadvent idxcivil{
gen `x'_p0 = `x' if partible==0
gen `x'_p1 = `x' if partible==1
gen `x'_w0 = `x' if womexc==1
gen `x'_w1 = `x' if womexc==0
}
collapse idxlent_p1 idxadvent_p1 idxcivil_p1 idxlent_p0 idxadvent_p0 idxcivil_p0 idxlent_w1 idxadvent_w1 idxcivil_w1 idxlent_w0 idxadvent_w0 idxcivil_w0, by(AN_MA)
tsset AN_MA
foreach x in idxlent idxadvent idxcivil{
tssmooth ma ma`x'_p0 = `x'_p0, window(2 1 2)
tssmooth ma ma`x'_p1 = `x'_p1, window(2 1 2)
tssmooth ma ma`x'_w0 = `x'_w0, window(2 1 2)
tssmooth ma ma`x'_w1 = `x'_w1, window(2 1 2)
}
twoway (line maidxcivil_p1 AN_MA, lcolor(stc1) lwidth(medthick)) ///
	   (line maidxcivil_p0 AN_MA, lcolor(stc2)  lwidth(medthin)) ///
	   (line maidxcivil_w1 AN_MA, lcolor(stc1) lp(dash) lwidth(medthick)) ///
	   (line maidxcivil_w0 AN_MA, lcolor(stc2)  lp(dash) lwidth(medthin)), ///
	   xlabel(1700(25)1775 1792 1815) xline(1792, lcolor(gray) lpattern(dash)) ///
	   ylabel(0(0.25)1.6) xtitle("marriage year") aspectratio(0.5) ///
	   legend(on order(1 "Partible" 2 "Impartible" 3 "Wom included" 4 "Wom excluded") rows(2) ring(0) position(11) nobox region(lstyle(none))) ///
	   text(1.28 1715 "Moving average (`yma' 1 `yma')", size(small)) graphregion(color(white) lc(white)) name(pB, replace)
graph export "$APPFIG/figureH1b.pdf", as(pdf) name("pB") replace
graph drop _all
* ==============================================================================


* ==============================================================================
* Figure H2: Balancedness on religiosity index.
* ------------------------------------------------------------------------------
// Partible vs impartible
use "$DAT/final-henry.dta", clear
keep if AN_MA>=1792 & AN_MA<=1815 & MOIS_MA!=99 & JOUR_MA!=99
drop if partible==.
collapse vidxcivil vidxadvent vidxlent partible, by(villagenum)
ttest vidxcivil, by(partible)
local pval1 = round(`r(p)', 0.01)
local locN = `r(N_1)'+`r(N_2)'
ttest vidxlent, by(partible)
local pval2 = round(`r(p)', 0.01)
ttest vidxadvent, by(partible)
local pval3 = round(`r(p)', 0.01)
collapse (mean) civ=vidxcivil (sd) sd_civ=vidxcivil (count) n_civ=vidxcivil (mean) adv=vidxadvent (sd) sd_adv=vidxadvent (count) n_adv=vidxadvent (mean) len=vidxlent (sd) sd_len=vidxlent (count) n_len=vidxlent, by(partible)
foreach x in civ len adv{
gen hi_`x' = `x' + invttail(n_`x'-1,0.025)*(sd_`x' / sqrt(n_`x'))
gen lo_`x' = `x' - invttail(n_`x'-1,0.025)*(sd_`x' / sqrt(n_`x'))
}
gen partible1 = partible
gen partible2 = partible+3
gen partible3 = partible2+3
twoway 	(bar len partible) ///
		(rcap hi_len lo_len partible1, lcolor(black)) ///
		(bar adv partible2) ///
		(rcap hi_adv lo_adv partible2, lcolor(black)) ///
		(bar civ partible3) ///
		(rcap hi_civ lo_civ partible3, lcolor(black)),	///
		text(1 0.5  "pval (diff!=0)" "= 0`pval1'", size(vsmall) box bcolor(white) fcolor(white) lcolor(white)) ///
		text(1 3.5  "pval (diff!=0)" "= 0`pval2'", size(vsmall) box bcolor(white) fcolor(white) lcolor(white)) ///
		text(1 6.5  "pval (diff!=0)" "= 0`pval3'", size(vsmall) box bcolor(white) fcolor(white) lcolor(white)) ///
		ylabel(0(0.25)1) xlabel(0 " Impartible" 1 " Partible" 3 " Impartible" 4 " Partible" 6 " Impartible" 7 "Partible", labsize(medlarge) angle(90))  	///
		legend(on order(1 "Lent" 3 "Advent" 5 "Lent & Advent") rows(1)) ///
		name(fig2panela, replace) graphregion(color(white)) ///
		note("Sample: `locN' communes in Henry; marriages in 1792-1815")
// Woman excluded vs included
use "$DAT/final-henry.dta", clear
keep if AN_MA>=1792 & AN_MA<=1815 & MOIS_MA!=99 & JOUR_MA!=99
drop if womexc==.
collapse vidxcivil vidxadvent vidxlent womexc, by(villagenum)
ttest vidxcivil, by(womexc)
local locN = `r(N_1)'+`r(N_2)'
local pval1 = round(`r(p)', 0.01) // Note that rounding does not work, so this p-val is later introduced mannually
ttest vidxlent, by(womexc)
local pval2 = round(`r(p)', 0.01)
ttest vidxadvent, by(womexc)
local pval3 = round(`r(p)', 0.01)
collapse (mean) civ=vidxcivil (sd) sd_civ=vidxcivil (count) n_civ=vidxcivil (mean) adv=vidxadvent (sd) sd_adv=vidxadvent (count) n_adv=vidxadvent (mean) len=vidxlent (sd) sd_len=vidxlent (count) n_len=vidxlent, by(womexc)
foreach x in civ len adv{
gen hi_`x' = `x' + invttail(n_`x'-1,0.025)*(sd_`x' / sqrt(n_`x'))
gen lo_`x' = `x' - invttail(n_`x'-1,0.025)*(sd_`x' / sqrt(n_`x'))
}
gen womexc1 = womexc
gen womexc2 = womexc+3
gen womexc3 = womexc2+3
twoway 	(bar len womexc1) ///
		(rcap hi_len lo_len womexc1, lcolor(black)) ///
		(bar adv womexc2) ///
		(rcap hi_adv lo_adv womexc2, lcolor(black)) ///
		(bar civ womexc3) ///
		(rcap hi_civ lo_civ womexc3, lcolor(black)),	///
		text(1 0.5  "pval (diff!=0)" "= 0`pval1'", size(vsmall) box bcolor(white) fcolor(white) lcolor(white)) ///
		text(1 3.5  "pval (diff!=0)" "= 0`pval2'", size(vsmall) box bcolor(white) fcolor(white) lcolor(white)) ///
		text(1 6.5  "pval (diff!=0)" "= 0`pval3'", size(vsmall) box bcolor(white) fcolor(white) lcolor(white)) ///
		ylabel(0(0.25)1) xlabel(0 "w included" 1 "w excluded" 3 "w included" 4 "w excluded" 6 "w included" 7 "w excluded", labsize(medlarge) angle(90))  	///
		legend(on order(1 "Lent" 3 "Advent" 5 "Lent & Advent") rows(1)) ///
		name(fig2panelb, replace) graphregion(color(white)) ///
		note("Sample: `locN' communes in Henry; marriages in 1792-1815")
// combined graph
grc1leg2 fig2panela fig2panelb, legendfrom(fig2panela) rows(1) graphregion(color(white))
graph export "$APPFIG/figureH2.pdf", as(pdf) name("Graph") replace
* ==============================================================================

timer off 1
timer list
